/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.sales.hanserver.action.hancadsa.finished.consts;

/**
 *
 * @author v
 */
public class FinishedSaleConsts {

    public static final String SELECT_MAX_SEQUENCE
            = new StringBuffer()
            .append(" select (ifnull(max(nr_sequencia),0) + 1) sequence")
            .append(" from  VENDA").toString();

    public static final String SELLER_BY_USER
            = new StringBuffer()
            .append(" select max(nr_sequencia) sequence")
            .append(" from  PESSOA_FISICA")
            .append(" where nm_usuario = ?").toString();

    public static final String INSERT_SALE
            = new StringBuffer()
            .append(" insert into VENDA (")
            .append("         nr_sequencia,")
            .append("         dt_venda,")
            .append("         nr_seq_pf_vendedor,")
            .append("         nr_seq_pf_cliente,")
            .append("         vl_total_venda,")
            .append("         vl_desconto_venda")
            .append(" ) values (")
            .append("         ?,")
            .append("         ?,")
            .append("         ?,")
            .append("         ?,")
            .append("         ?,")
            .append("         ?)")
            .toString();

    public static final String INSERT_ITEM_SALE
            = new StringBuffer()
            .append(" insert into VENDA_ITEM (")
            .append("         nr_sequencia,")
            .append("         vl_unitario,")
            .append("         qt_produto,")
            .append("         nr_seq_venda,")
            .append("         nr_seq_produto")
            .append(" ) values (")
            .append("         0,")
            .append("         ?,")
            .append("         ?,")
            .append("         ?,")
            .append("         ?)")
            .toString();

    public static final String UPDATE_PRODUCT_SALES = "update PRODUTO set qt_estoque = (qt_estoque - ?) where nr_sequencia = ?";
}
